//
//  ChildrenViewController.m
//  XMLY
//
//  Created by 曾杰 on 15/11/4.
//  Copyright © 2015年 曾杰. All rights reserved.
//

#import "ChildrenViewController.h"
#import "HACursor.h"
#import "ChildListViewController.h"
#import "ChildrenRecommendViewController.h"
@interface ChildrenViewController ()

@property (nonatomic, strong)HACursor *cursor;
@property (nonatomic, strong)NSMutableArray * pageViews;
@property (nonatomic, strong) NSArray *items;
@property (nonatomic, strong) ChildrenRecommendViewController *childRecommendVC;
@property (nonatomic, strong) ChildListViewController *childDetailVC;
@end

@implementation ChildrenViewController

- (NSArray *)items{
    if (_items == nil) {
        _items = @[@"推荐", @"睡前故事", @"童话故事", @"儿歌总汇", @"胎教殿堂",@"儿童英语", @"儿童科普", @"儿童教育"];
    }
    return _items;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.titleLabel.text = @"儿童乐园";
    //不允许有重复的标题
    _cursor = [[HACursor alloc]initWithTitles:self.items AndPageViews:self.pageViews];
    _cursor.frame = CGRectMake(0, 64, SCREEN_WIDTH, 45);
//    _cursor.titles = self.items;
    _cursor.pageViews = [self createPageViews];
    //设置根滚动视图的高度
    _cursor.rootScrollViewHeight = self.view.frame.size.height -109;
    //默认值是白色
    _cursor.titleNormalColor = [UIColor blackColor];
    //默认值是白色
    _cursor.titleSelectedColor = [UIColor redColor];
    //是否显示排序按钮
    _cursor.showSortbutton = NO;
    //默认的最小值是5，小于默认值的话按默认值设置
    _cursor.minFontSize = 15;
    //默认的最大值是25，小于默认值的话按默认值设置，大于默认值按设置的值处理
    _cursor.maxFontSize = 18;
    //cursor.isGraduallyChangFont = NO;
    //在isGraduallyChangFont为NO的时候，isGraduallyChangColor不会有效果
    //cursor.isGraduallyChangColor = NO;
    [self.view addSubview:_cursor];
    // Do any additional setup after loading the view.
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(NSMutableArray *)createPageViews
{
    self.pageViews = [NSMutableArray arrayWithCapacity:0];
    _childRecommendVC = [[ChildrenRecommendViewController alloc]init];
    [_pageViews addObject:_childRecommendVC.view];
    
    for (int i = 1; i< self.items.count; i++) {
        _childDetailVC = [[ChildListViewController alloc]init];
        
        switch (i) {
           
            case 1:
            {
               
                _childDetailVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=6&device=android&pageId=1&pageSize=20&status=0&tagName=%E7%9D%A1%E5%89%8D%E6%95%85%E4%BA%8B";
                
            }
                break;
            case 2:
            {
                _childDetailVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=6&device=android&pageId=1&pageSize=20&status=0&tagName=%E7%AB%A5%E8%AF%9D%E6%95%85%E4%BA%8B";
                
            }break;
            case 3:
            {
                _childDetailVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=6&device=android&pageId=1&pageSize=20&status=0&tagName=%E5%84%BF%E6%AD%8C%E5%A4%A7%E5%85%A8";
            }
                break;
            case 4:
            {
                 _childDetailVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=6&device=android&pageId=1&pageSize=20&status=0&tagName=%E8%83%8E%E6%95%99%E6%AF%8D%E5%A9%B4";
                
            }
                break;
                
            case 5:
            {
                _childDetailVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=6&device=android&pageId=1&pageSize=20&status=0&tagName=%E5%84%BF%E7%AB%A5%E8%8B%B1%E8%AF%AD";
                
            }
                break;
                
            case 6:
            {
                _childDetailVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=6&device=android&pageId=1&pageSize=20&status=0&tagName=%E5%84%BF%E7%AB%A5%E7%A7%91%E6%99%AE";
                
            }
                break;
            case 7:
            {
                _childDetailVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=6&device=android&pageId=1&pageSize=20&status=0&tagName=%E5%84%BF%E7%AB%A5%E6%95%99%E8%82%B2";
              
                
            }
                break;
                
        }
        
        [_pageViews addObject:_childDetailVC.view];
    }
    return _pageViews;
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
